package com.wxl.common.room.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.wxl.common.room.dao.UserDao;
import com.wxl.common.room.entity.UserEntity;

@Database(entities = {UserEntity.class}, version = 1,exportSchema = false)
public abstract class DataBase extends RoomDatabase {

    private static DataBase mDataBase;


    public static synchronized DataBase getInstance(Context mContext) {
        if (mDataBase == null) {
            mDataBase = Room.databaseBuilder(mContext.getApplicationContext(), DataBase.class, "db_blast")
                    //.allowMainThreadQueries()
                    //不允许在主线程对数据库进行操作,为了方便测试可以加入该方法强行允许在主线程进行CURD操作
                    .build();
        }
        return mDataBase;
    }

    public abstract UserDao getUserDao();

}
